blob: 8d173edba185ae543202a172bcf7b3fe27abdd4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import { getPost, getPostSlugs } from '$lib/utils/posts';
import { error } from '@sveltejs/kit';
import type { PageLoad } from './$types';
export const prerender = true;
// Generate all post routes at build time
export function entries() {
return getPostSlugs().map((slug) => ({ slug }));
}
export const load: PageLoad = async ({ params }) => {
const slug = params.slug;
const post = await getPost(slug);
if (!post) {
error(404, `Post not found: ${slug}`);
}
return {
content: post.default,
metadata: post.metadata,
slug
};
};
|